package operation;

import book.Book;
import book.BookShelf;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void working(BookShelf bookShelf) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要借阅图书的名称：");
        String name = scanner.next();

        int currentSize = bookShelf.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookShelf.getBooks(i);
            if(book.getName().equals(name)){
                System.out.println("借阅成功");
                book.setBorrowed(true);
                System.out.println(book);
                return;
            }
        }

        System.out.println("未找到这本书");
    }
}
